package com.ayf.payment.game.api.utils;

import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author ad
 * @Title: MyReturnJsonUtil
 * @Copyright: Copyright (c) 2020
 * @Description: <br>
 * @Company: a.com
 * @Created on 2020/7/1621:20
 */
public final class MyReturnJsonUtil {

    public static void printErrMsg(HttpServletResponse response, String errorMsg){
        PrintWriter printWriter=null;
        try {
            CommonResult commonResult = new CommonResult();
            commonResult.setCode(-1);
            commonResult.setMsg(errorMsg);
            response.setContentType("application/json;charset=UTF-8");
            printWriter = response.getWriter();
            printWriter.println(JSONObject.toJSONString(commonResult));
            printWriter.flush();
        } catch (IOException ex) { }finally {
            if (printWriter!=null){printWriter.close();}
        }
    }


}
